package com.tqjc.system.C24012.core.config.websocket.service.impl;

import com.alibaba.fastjson.JSON;
import com.tqjc.system.C24012.core.config.websocket.service.MessageSendService;
import com.tqjc.system.core.util.UUIDUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

/**
 * @Author: 86195
 * @CreateTime: 2024-07-04  15:56
 * @Description: TODO
 * @Version: 1.0
 */
@Service
@Slf4j
public class MessageSendServiceImpl implements MessageSendService {

    @Resource
    private SimpMessageSendingOperations simpMessageSendingOperations;

    @Override
    @Scheduled(cron = "0/1 * *  * * ? ")
    @Async
    public void sendCraneIndexInfo() {
        String uuid = UUIDUtil.getUUID();
        simpMessageSendingOperations.convertAndSend("/topic/craneIndexInfo", JSON.toJSONString(uuid));

    }
}
